<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language="JavaScript">
function validateEntries(theForm){
  if (theForm.maxFind.value == "") {
    alert('<bean:message key="cs.error.maximum.number.find"/>');
    return;
  } else {
    var num = parseInt(theForm.maxFind.value, 10);
    if (isNaN(num)) {
      alert('<bean:message key="cs.error.maximum.number.find.integer"/>');
      return;
    }
    if (num > 0) {
      theForm.maxFind.value = num;
    } else {
      alert('<bean:message key="cs.error.maximum.number.find.greater.than.zero"/>');
      return;
    }
  }
  theForm.submit();
  return;
}

function closeWindow() {
  self.close();
}

var checkflag = "false";
function check(field) {
  var SelectAllTxt = '<bean:message key="button.selectAll"/>';
  var UnselectAllTxt = '<bean:message key="button.unselectAll"/>';
 
  if(field == null) return SelectAllTxt;

  var max = field.length;

  if(max > 1) {
    if (checkflag == "false") {
      for (i = 0; i < max; i++) {
        field[i].checked = true;
      }
      checkflag = "true";
      return UnselectAllTxt;
    } else {
      for (i = 0; i < max; i++) {
        field[i].checked = false;
      }
      checkflag = "false";
      return SelectAllTxt;
    }
  } else {
    if (checkflag == "false") {
      field.checked = true;
      checkflag = "true";
      return UnselectAllTxt;
    } else {
      field.checked = false;
      checkflag = "false";
      return SelectAllTxt;
    }
  }
}

function refreshParentWindow(theForm, closeWindow) {
  var userList = new Array;
  var index = 0; 
  if ( theForm.usrChkBox != null ) {
    var len = theForm.usrChkBox.length;
    if ( len > 1 ) {
      for ( var i=0; i<len; i++ ) {
        if ( theForm.usrChkBox[i].checked ) {
          userList[index] = theForm.usrChkBox[i].value;
          index++;
        }
      }
    } else {
      if ( theForm.usrChkBox.checked ) {
        userList[0] = theForm.usrChkBox.value;
      }
    }
    if ( userList.length > 0 ) {
      window.opener.refreshParticipants(userList);
    } 
  }
  if ( closeWindow ) {
    self.close();
  } else {
    location='<html:rewrite page="/cs/participantFind.do" name="micrositeNaviInfoView" property="urlParams" />';
  }
}

</script>


<!-- BEGIN form ( csParticipantFindForm ) -------------------------->
<html:form action="/cs/participantFind.do">
<bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>

<!-- Zone 5 starts here.  -->
      
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
	
	<!-- close window button here -->
	  <div class="generalWrapRight">
        <html:button property="closeBtn" titleKey="button.close.window" styleClass="inputButton" onclick="javascript:closeWindow()">
          <bean:message key="button.close.window" />
        </html:button>
      </div>
	<!-- end button -->
	
    <!--start page title here-->
      <div class="pageTitle">
        <bean:message key="cs.find.more.user.participants"/>
      </div> 
    <!--end page title here-->
    
    <!--start sub title bar here-->
    <div class="pageSubtitle">
      <span class="left">
        <bean:message key="cs.find"/>
      </span>
	  <span class="right">&nbsp;</span>
    </div>  
    
    <div class="blockWrap">
      
    <!-- start Page Instructions -->
    <div class="pageInstructions">
    <c:if test="${micrositeNaviInfoView.map.isMicrosite}">
      <bean:message key="cs.participant.find.user.note.microsite"/>
    </c:if>
    <c:if test="${!micrositeNaviInfoView.map.isMicrosite}">
      <bean:message key="cs.participant.find.user.note"/>
    </c:if>
    </div>
    <!-- End Page Instructions -->

    
      
    <!--start main content area here-->
    <table class="labelForm" width="100%" border="0" cellspacing="0" 
           cellpadding="0" summary="Find participants Rules">

      <logic:equal name="participantFindView" property="usingFMLName" value="true">
      <tr>
        <td nowrap width="30%" class="label">
          <bean:message key="cs.firstName"/>:
        </td>
        <td width="70%" class="labelField" align=left>
          <html:text property="firstName" maxlength="30"/>
        </td>
      </tr>
      <tr>
        <td nowrap width="30%" class="label">
          <bean:message key="cs.lastName"/>:
        </td>
        <td width="70%" class="labelField" align=left>
          <html:text property="lastName" maxlength="30"/>
        </td>
      </tr>
      </logic:equal>

      <logic:equal name="participantFindView" property="usingFMLName" value="false">
      <tr> 
        <td nowrap width="30%" class="label">
          <bean:message key="cs.user.name"/>:
        </td>
        <td width="70%" class="labelField" align=left>
          <html:text property="userAlias" maxlength="30"/>
        </td>
      </tr>
      </logic:equal>
      
      <tr>
        <td class="label"><bean:message key="cs.find.search.string"/>:</td>
        <td class="labelField" align=left>
          <html:radio property="searchStringAnywhere" value="false"/>
          <bean:message key="cs.find.beginning.name"/>
        </td>
      </tr>
      
      <tr>
        <td class="label">&nbsp;</td>
        <td class="labelField" align=left>
          <html:radio property="searchStringAnywhere" value="true"/>
          <bean:message key="cs.find.anywhere.name"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="cs.find.max.to.find"/>:</td>
        <td class="labelField" align=left>
          <html:text property="maxFind" maxlength="4" size="4"/>
        </td>
      </tr>

      <tr>
        <td width="30%" class="label"><bean:message key="cs.find.city"/>:</td>
        <td width="70%" class="labelField" align=left>
          <html:text property="city" maxlength="30" />
        </td>
      </tr>
          
      <tr>
        <td width="30%" class="label"><bean:message key="cs.find.state"/>:</td>
        <td width="70%" class="labelField" align=left>
          <html:text property="state" maxlength="30" />
        </td>
      </tr>
      
      <tr>
        <td width="30%" class="label"><bean:message key="cs.find.country"/>:</td>
        <td width="70%" class="labelField" align=left>
          <html:text property="country" maxlength="30" />
        </td>
      </tr>
                  
      <%--          
      <bean:define id="selectedQualifierValues" property="selectedQualifierValues" name="csParticipantFindForm"/>
      <logic:iterate id="qualifier" property="qualifiers" name="csParticipantFindForm" type="Qualifier">
        <bean:define id="values" name="qualifier" property="values"/>
        <tr>
          <td nowrap class="label"><bean:write name="qualifier" property="name"/>:</td>
          <td width="100%"><html:select name="csParticipantFindForm" property="selectedQualifierValues" size="5" multiple="true"><html:options collection="values" property="qualifierValueId" labelProperty="name"/></html:select></td>
        </tr>
      </logic:iterate>
      --%>
    </table>
    <div class="pageButtonWrap" align="right">  
      <html:button property="showResultBtn" titleKey="button.show.results" styleClass="pageButton" onclick="javascript:validateEntries(this.form)">
        <bean:message key="button.show.results" />
      </html:button>
    </div>  
    
    </div>
    
    
	
    <logic:equal name="csParticipantFindForm" property="findParticipants" value="true">
    <!--start sub title bar here-->
    <div class="pageSubtitle">
      <span class="left">
        <bean:message key="cs.participants"/>
      </span>
    </div>  

    <div class="blockWrap">

    <div class="globalButtonWrap">
      <input type="button" name="selectAll" class="globalButton"
             onclick="this.value=check(this.form.usrChkBox)" 
             value="<bean:message key='button.selectAll'/>"> 
    </div>
     
    <!-- Start List here -->
    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" 
           summary="Search result table" width="100%">
      
      <logic:empty name="participantFindView" property="userList">
        <tr class="listOdd">
          <td align="center" colspan=3><bean:message key="cs.find.zero.item"/>
          </td>
        </tr>
      </logic:empty>
      <logic:notEmpty name="participantFindView" property="userList">
        <tr class="listHeader"> 
          <th id="select" align="center"><bean:message key="cs.select"/></th>
          <th id="login" align="left"><bean:message key="cs.login"/></th>
          <th id="name" align="left"><bean:message key="cs.name"/></th>
        </tr>
               
        <logic:iterate id="oneUser" name="participantFindView" property="userList" indexId="index">
          <tr class='<%= index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'>
            <td headers="select" align="center">
              <logic:equal name="oneUser" property="participant" value="true">
                <html:img page="/cs/images/icons/cicon_checkmark.gif" alt=""/>
              </logic:equal>
              <logic:notEqual name="oneUser" property="participant" value="true">
                  <input type="checkbox" name="usrChkBox" value='<bean:write name="oneUser" property="userId" />' >
              </logic:notEqual>
            </td>
            <td headers="login" align="left"><bean:write name="oneUser" property="USER_ALIAS" /></td>
            <td headers="name" align="left"><bean:write name="oneUser" property="fullName" /></td>
          </tr>
        </logic:iterate>
      </logic:notEmpty> 
    </table>
    <!--start cancel, reset, save bar area here-->
    <div class="pageButtonWrap" align="right">
      <html:button property="cancelBtn" titleKey="button.cancel" styleClass="pageButton" onclick="javascript:closeWindow()">
         <bean:message key="button.cancel" />
      </html:button>
      <logic:equal name="participantFindView" property="hasCandidate" value="true">
        <html:button titleKey="cs.find.add.continue" property="addContinueBtn" onclick="refreshParentWindow(this.form,false)" styleClass="pageButton">
          <bean:message key="cs.find.add.continue" />
        </html:button> 
        <html:button titleKey="cs.find.add.done" property="addDoneBtn" onclick="refreshParentWindow(this.form, true)" styleClass="pageButton">
          <bean:message key="cs.find.add.done" />
        </html:button> 
      </logic:equal>
    </div>     
    <!--End cancel, reset, save bar area here-->
    </logic:equal> <%-- end of csParticipantFindForm.findParticipants == true. --%>

     </div>

      </td>
    </tr>
  </table> 
  <input type=hidden name=findParticipants value="true"/>
</html:form>
  
<!-- END form ( csParticipantFindForm ) ---------------------------->
